//
//  LeftRootViewController.m
//  BProject
//
//  Created by 久远的回忆 on 15/8/11.
//  Copyright (c) 2015年 久远的回忆. All rights reserved.
//

#import "LeftRootViewController.h"
#import "CommonData.h"
#import "RightRootViewController.h"
@interface LeftRootViewController () <UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong) UITableView * mainTableView;
@property (nonatomic,strong) RightRootViewController *rightVC;
@end

@implementation LeftRootViewController

- (void)createTableView{
    _mainTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 150, SCREEN_WIDTH - 70, 400) style:UITableViewStylePlain];
    _mainTableView.separatorColor =[UIColor clearColor];
    _mainTableView.separatorInset =UIEdgeInsetsMake(0, 30, 0, 0);
    _mainTableView.delegate = self;
    _mainTableView.dataSource = self;
    [_mainTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"rootLeftMainCell"];
    
    [self.view addSubview:_mainTableView];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self createTableView];
    _rightVC = [[RightRootViewController alloc]init];
    [self.view addSubview:_rightVC.view];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [CommonData defaultData].titleArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"rootLeftMainCell" forIndexPath:indexPath];
    cell.backgroundColor = [UIColor lightGrayColor];
    cell.textLabel.text = [CommonData defaultData].titleArray[indexPath.row];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [_rightVC changeViewWithIndex:indexPath.row];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
